package router0

import (
	"net/http"
	assets0 "searcher/src/assets"

	"github.com/gin-gonic/gin"
)

type WebRouters struct{}

func (w *WebRouters) AllRouters(r *gin.Engine) {
	w.favicon_ico(r)             // favicon.ico
	w.static_for_vue_frontend(r) // 静态资源
	w.index(r)                   // 首页

	//
	all_routers_for_search_tool(r)
}

// favicon.ico
func (*WebRouters) favicon_ico(r *gin.Engine) {
	r.GET("/favicon.ico", func(c *gin.Context) {
		c.Header("Content-type", "application/x-ico")
		c.String(http.StatusOK, string(assets0.Favicon_ico))
	})
}

// index
func (*WebRouters) index(r *gin.Engine) {
	r.GET("/", func(c *gin.Context) {
		c.Header("Content-type", "text/html;charset=utf-8")
		c.String(http.StatusOK, string(assets0.IndexPublic))
	})
}

// 静态资源
func (*WebRouters) static_for_vue_frontend(r *gin.Engine) {
	r.StaticFS("/public", http.FS(assets0.NewAssetsPublic()))
}
